<?php
/**
* @project ApPHP Medical Appointment
* @copyright (c) 2012 ApPHP
* @author ApPHP <info@apphp.com>
* @license http://www.gnu.org/licenses/
*/

// *** Make sure the file isn't accessed directly
defined('APPHP_EXEC') or die('Restricted Access');
//--------------------------------------------------------------------------

$search_type      = isset($_POST['search_type']) ? prepare_input($_POST['search_type']) : '';
$sel_specialities = isset($_POST['sel_specialities']) ? prepare_input($_POST['sel_specialities']) : '';
$doctor_name      = isset($_POST['doctor_name']) ? prepare_input($_POST['doctor_name']) : '';
$search_string    = ($search_type == 'by_speciality') ? $sel_specialities : $doctor_name;

draw_title_bar(_SEARCH_RESULTS);

if(empty($search_type)){
    draw_important_message(_WRONG_PARAMETER_PASSED);
}else if($search_type == 'by_speciality' && empty($sel_specialities)){
    draw_important_message(_NO_SPECIALITY_SELECTED);    
}else if($search_type == 'by_name' && empty($doctor_name)){
    draw_important_message(_DOCTOR_NAME_EMPTY_ALERT);    
}else{
    $result = Doctors::SearchFor($search_type, $search_string);
    Doctors::DrawSearchResult($result, $search_type, $sel_specialities);    
}
	
?>